package com.trade.module.database.service;




import com.trade.module.database.dao.QueryRecordDao;
import com.trade.module.database.entity.QueryRecord;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

/**
 * 查询记录处理service类
 * Created by wagnchun on 2016/4/5.
 */
public class QueryRecordService {

    private static QueryRecordService instance;

    private QueryRecordService() {
    }

    public static QueryRecordService getInstance() {
        if (instance == null) {
            instance = new QueryRecordService();
        }
        return instance;
    }

    public boolean saveQueryRecord(QueryRecord queryRecord) throws Exception {
        QueryRecordDao.getInstance().saveQueryRecord(queryRecord);
        return true;
    }

    public boolean saveQueryRecordBatch(List<QueryRecord> queryRecordList) throws Exception {
        QueryRecordDao.getInstance().saveQueryRecordBatch(queryRecordList);
        return true;
    }

    public List<String> getTableIdList(String dbName, String tableName, String taskId) throws SQLException {
        return QueryRecordDao.getInstance().getTableIdList(dbName, tableName, taskId);
    }

    public Date getMaxCreateTime(String dbName, String tableName, String taskId) throws SQLException {
        return QueryRecordDao.getInstance().getMaxCreateTime(dbName, tableName, taskId);
    }

    public Date getMaxUpdateTime(String dbName, String tableName, String taskId) throws SQLException {
        return QueryRecordDao.getInstance().getMaxUpdateTime(dbName, tableName, taskId);
    }

    public void dropMongodbRecordByTaskId(String taskId) {
        QueryRecordDao.getInstance().dropRecordByTaskId(taskId);
    }

}
